
//
//  ThemeDetailViewController.m
//  DaJiang
//
//  Created by sally on 16/10/10.
//  Copyright © 2016年 jiniu. All rights reserved.
//

#import "ThemeDetailViewController.h"
#import <UMSocialCore/UMSocialCore.h>
#import <UShareUI/UMSocialUIManager.h>

@interface ThemeDetailViewController ()

@property (weak, nonatomic) IBOutlet UILabel *titleLabel;
@property (weak, nonatomic) IBOutlet UILabel *timeLabel;
@property (weak, nonatomic) IBOutlet UILabel *seenLabel;
@property (weak, nonatomic) IBOutlet UILabel *scoreLabel;
@property (weak, nonatomic) IBOutlet UILabel *descLabel;
@property (weak, nonatomic) IBOutlet UIButton *priceBtn;

@end

@implementation ThemeDetailViewController

- (void)viewDidLoad {
  [super viewDidLoad];
  //TODO: 文本可能要替换成web或者scrollview（滚动看到全部）-暂不管
  [self initControl];
  [self loadControl];
}

#pragma mark 初始化控件
- (void)initControl {
  self.title = @"话题";
  UIButton *rightBtn = [[CommonMethod sharedCommonMethod] navigationItemWithImage:@"share_ic"];
  [rightBtn addTarget:self action:@selector(rightAction) forControlEvents:UIControlEventTouchUpInside];
  self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:rightBtn];
  //设置文本下边距>=12，解决可能会超过范围又居中的问题
}

#pragma mark 装载控件
- (void)loadControl {
  TopicData *topicData = self.topicModel.data;
  self.titleLabel.text = topicData.topic_name;
  self.timeLabel.text = [NSString stringWithFormat:@"约%@", topicData.time_length];
  self.seenLabel.text = [NSString stringWithFormat:@"%ld人见过",(long)topicData.consulting_count];
  self.scoreLabel.text = [NSString stringWithFormat:@"%.1f分",topicData.pro_topic_consulting_comment_avg_value];
  self.descLabel.text = topicData.topic_desc;
  [self.priceBtn setTitle:[NSString stringWithFormat:@"¥%.2f", topicData.topic_price] forState:UIControlStateNormal];
}

#pragma mark - action
#pragma mark 点击预约
- (IBAction)actionOnOrder:(id)sender {
  OrderDetailViewController *vc = [OperationManager gotoOrderDetailVcWithType:OrderDetailType_Normal status:OrderNormalStatus_FillIn];
  vc.expertDetail = self.expertDetailModel;
  vc.topicModel = self.topicModel;
}

#pragma mark - 私有方法
#pragma mark 分享（导航栏右按钮）
- (void)rightAction {
  //显示分享面板
  [UMSocialUIManager showShareMenuViewInWindowWithPlatformSelectionBlock:^(UMSocialPlatformType platformType, NSDictionary *userInfo) {
    //设置分享内容 分享文案：话题名/推荐专家名  +  话题内容/专家介绍  + 头像（图片）
    TopicData *topicData = self.topicModel.data;
    if (self.expertDetailModel.pro_user_info.count > 0) {
      UserModel *userModel = self.expertDetailModel.pro_user_info[0];
      NSString *url = [NSString stringWithFormat:@"http://%@/portal/index/topic/%ld",H5_API_HOST,(long)self.topicModel.topicid];
      [OperationManager shareWebPageToPlatformType:platformType title:topicData.topic_name desc:topicData.topic_desc imageUrl:userModel.user_data.user_profile_pic webUrl:url];
    }
  }];
}

@end
